package core

import "matcher/pkg/lib/helper"

type DepthItem struct {
	Price  string `json:"price"`
	Amount string `json:"amount"`
}

type Depth struct {
	Asks []DepthItem `json:"asks"` // 卖
	Bids []DepthItem `json:"bids"` // 买
}

type NumericStrings []string

func (c NumericStrings) Len() int {
	return len(c)
}

func (c NumericStrings) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func (c NumericStrings) Less(i, j int) bool {
	var pi = helper.NewDecimal(c[i])
	var pj = helper.NewDecimal(c[j])
	return pi.LessThan(pj)
}

func (c NumericStrings) Reverse() {
	var m = c.Len()
	var n = m / 2
	for i := 0; i < n; i++ {
		c[i], c[m-i-1] = c[m-i-1], c[i]
	}
}
